<?php

/**
 * Echantillon form base class.
 *
 * @method Echantillon getObject() Returns the current form's model object
 *
 * @package    appcemhti
 * @subpackage form
 * @author     Steve Cancès
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseEchantillonForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id_echantillon'      => new sfWidgetFormInputHidden(),
      'id_etat_echantillon' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('EtatEchantillon'), 'add_empty' => false)),
      'id_lot'              => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Lot'), 'add_empty' => false)),
      'id_type_forme'       => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('TypeForme'), 'add_empty' => true)),
      'id_lieu'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Lieu'), 'add_empty' => true)),
      'id_user'             => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('User'), 'add_empty' => false)),
      'nom'                 => new sfWidgetFormInputText(),
      'created_at'          => new sfWidgetFormDateTime(),
      'updated_at'          => new sfWidgetFormDateTime(),
      'date_creation'       => new sfWidgetFormDate(),
      'epaisseur'           => new sfWidgetFormInputText(),
      'diametre'            => new sfWidgetFormInputText(),
      'longueur'            => new sfWidgetFormInputText(),
      'largeur'             => new sfWidgetFormInputText(),
      'rectangle'           => new sfWidgetFormInputText(),
      'a'                   => new sfWidgetFormInputText(),
      'b'                   => new sfWidgetFormInputText(),
      'c'                   => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id_echantillon'      => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id_echantillon')), 'empty_value' => $this->getObject()->get('id_echantillon'), 'required' => false)),
      'id_etat_echantillon' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('EtatEchantillon'))),
      'id_lot'              => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Lot'))),
      'id_type_forme'       => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('TypeForme'), 'required' => false)),
      'id_lieu'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Lieu'), 'required' => false)),
      'id_user'             => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('User'))),
      'nom'                 => new sfValidatorString(array('max_length' => 32)),
      'created_at'          => new sfValidatorDateTime(array('required' => false)),
      'updated_at'          => new sfValidatorDateTime(array('required' => false)),
      'date_creation'       => new sfValidatorDate(array('required' => false)),
      'epaisseur'           => new sfValidatorNumber(array('required' => false)),
      'diametre'            => new sfValidatorNumber(array('required' => false)),
      'longueur'            => new sfValidatorNumber(array('required' => false)),
      'largeur'             => new sfValidatorNumber(array('required' => false)),
      'rectangle'           => new sfValidatorInteger(array('required' => false)),
      'a'                   => new sfValidatorNumber(array('required' => false)),
      'b'                   => new sfValidatorNumber(array('required' => false)),
      'c'                   => new sfValidatorNumber(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('echantillon[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Echantillon';
  }

}
